<extend name="Base/common"/>
<block name="header">  {:hook('mobileTopNav',array('title'=>$meta_title))} </block>
<block name="body">
<link href="__CSS__/order.css" rel="stylesheet">
  <div class="order">
    <form action="{:U('add')}" id="Z_checkout_form" method="post">
      <!-- 收货地址 -->
      <h4>收货地址</h4>
      <notempty name="data.default_receiver"> <a href="{:U('Receiver/index/buynow/'.$buynow)}" class="receiver">
        <h5>{$data.default_receiver.name}</h5>
        <p class="city" data-text='{$city}'>{$data.default_receiver.area}{$data.default_receiver.address}</p>
        <p>{$data.default_receiver.mobile}</p>
        <i class="icon icon-arrow-right"></i>
        <input type="radio" name="receiver_id" class="hide" value="{$data.default_receiver.id}" checked="checked">
        </a>
        <else/>
        <div class="content-padded"> <a href="{:U('Receiver/index')}" class="btn btn-block btn-positive">选择收货地址</a> </div>
      </notempty>
      
      <!-- 付款方式 -->
      <h4>付款方式</h4>
      <ul class="payment" id="Z_payment">
        <if condition="is_weixin()">
          <li class="item selected"> <span class="icon weixin"></span>
            <input type="radio" name="payment_type" value="wechatpay" checked="checked">
            <em class="arrow"></em> 
          </li>
          <li class="item"> <span class="icon alipay"></span>
            <input type="radio" name="payment_type" value="alipaywap">
            <em class="arrow"></em> 
          </li>
        <else/>
          <li class="item selected"> <span class="icon alipay"></span>
            <input type="radio" name="payment_type" value="alipaywap" checked="checked">
            <em class="arrow"></em> 
          </li>
          <if condition="is_app()">
            <li class="item"> <span class="icon weixin"></span>
              <input type="radio" name="payment_type" value="wechatpay">
              <em class="arrow"></em> 
            </li>
          </if>
          
        </if>
      </ul>
      <if condition="C('IS_RECEIPT') eq 1">
        <!-- 发票信息 -->
        <h4>发票信息</h4>
        <p class="payment"> <span> 不开发票&nbsp</span> <a class="text-danger" href="#invoice" >修改</a> </p>
      </if>
      <if condition="C('REAL_NAME') eq 1">
        <!-- 发票信息 -->
        <h4>实名信息认证</h4>
        <p class="payment" style="font-size: 0.7em;"><em style="color:rgb(43,135,1)">温馨提示</em>：因涉及国家监管部门规定，需要核对购买人信息，网站不会保留相关个人信息，请放心购买</p>
        <p class='payment' style="padding: 5px;">
        <span>真实姓名：</span>
        <input type="text" class="form-control rname" name="realname" placeholder="请填写真实姓名" style="width: 70%;height: 2.5em;">
        </p><p class='payment' style="padding: 5px;">
       <span>身份证号：</span> 
       <input type="text" class="form-control input-sm idcard" name="idcard" placeholder="请填写与姓名相符的身份证号" style="width: 70%;height: 2.5em;">
       </p>
      </if>
      <h4>商品清单 <span class="pr-h4">共 <span class="text-danger" id='J_delivery_num'>{$order_count['total_quantity']}</span> 件商品</span></h4>
      <div class="items">
        <notempty name="data.items">
          <div class="package order_attr" data-attr='1'>
            <volist name="data.items" id="supp">
              <div class="supplier-box">
                <div class="supplier-title">
                  <span class="is-self"><gt name="supp.store_id" value="0">{$supp.store_name}<else />自营</gt></span>
                  <php>$manjian = get_store_manjian($supp['store_id']);</php>
                  <notempty name="manjian.msg">
                  <span class="col-xs-2 manjian-items" data-man="{$manjian.man}" data-jian="{$manjian.code}">
                  <i style="color: #FFF;background: #f28659;padding: 2px 5px;font-size: 12px;border-radius: 3px;margin-right: 8px;margin-left:4%;">{$manjian['msg']}</i></span>
                  <else />
                  <span class="col-xs-2 manjian-items" data-man="0" data-jian="0"></span>
                  </notempty>
                  <div class="display:none;">
                    <input type="hidden" name="delivery_id[{$supp['store_id']}]" class="J_delivery_id" id="wuliu{$supp['store_id']}" value="{$data['delivery'][$supp['store_id']]['price']}" data-price="{$data['delivery'][$supp['store_id']]['price']}" />       
                    <span class="pull-right">{$data['delivery'][$supp['store_id']]['msg']}</span>
                  </div>
                </div>
                <volist name="supp.item" id="vo">
                  <div class="item item_{$vo['item_id']}_{$vo['item_code']}" >
                    <div class="pic"><img src="__ROOT__{:get_image_thumb($vo['cover_path'], 100, 100)}" width="58" height="58"></div>
                    <div class="name">{$vo['name']}</div>
                    <if condition="$vo['stock'] lt $vo['quantity'] && !C('START_POSITION')"><em class="text-danger">此商品所购买数量大于库存</em></if>
                    <notempty name="vo.spec">
                      <div class="spec">
                        <volist name="vo.spec" id="vl"> <span class="mr-sm">{$vl.key}：{$vl.val}</span> </volist>
                      </div>
                    </notempty>
                    <div class="attr"> <span class="text-danger danjia1"> &yen;<i class="danjia">{$vo['price']} </i>&times; {$vo['quantity']}
                      <if condition="$vo.dis_price gt 0"><span class="price-tip">老客户立减</span></if>
                      <if condition="$vo['discount_name']"> <span class="price-tip">{$vo.discount_name}</span> </if>
                      </span> 
                      <input type="hidden" class="zongjia" value="{$vo['subAmount']}" />
                    </div>
                  </div>
                </volist>
                <div class="send-items Z_send_supp_{$supp.store_id}"></div>
              </div>
              <!--{//店铺合计BOX}-->
              <div class="row">
                <!--{//留言}-->
                <input type="text" placeholder="选填，可以留言给卖家"  name="memo[{$supp.store_id}]" style=" margin-bottom:0; border:none; padding-top:0;border-bottom:1px dotted #e5e5e5"  />
                <!--{//优惠券}-->
                <gt name="supp.coupon_total" value="0">
                <div class="table-view-cell Z_itemlist S_order_coupon_box" data-store="{$supp.store_id}" id="Z_order_coupon_box_{$supp.store_id}">
                  <i class="icon icon-square"></i>使用优惠券（<em class="text-danger">有可用优惠券</em>） 
                  <i class="icon icon-arrow-bottom"></i> 
                </div>
                </gt>
                <!--{//优惠券BOX}-->
              <div class="payment-box hide Z_itemlist" id="Z_coupon_box_{$supp.store_id}">
                <!--{//优惠券列表}-->
                <div class="con-item-bd" style="padding:10px; line-height:2em; background-color:rgba(255,255,255,0.6); border-bottom: 1px dotted #e5e5e5 ">
                  <ul class="coupon-list" id="Z_coupon_list_{$supp.store_id}">
                      <volist name="supp.coupon_lists" id="vo">
                        <li>
                          <label for="coupon_store_item_{$vo.Coupon.id}">
                            <input type="radio" name="store_coupons[]" value="{$vo.Coupon.number}" id="coupon_store_item_{$vo.Coupon.id}" />
                            <i>{$vo.Coupon.name}（<eq name="vo.Coupon.norm" value="0">全场不限制<else/>满{$vo.Coupon.norm}元使用</eq>）</i> 
                            <span>{$vo.Coupon.amount} 元</span> 
                          </label>
                        </li>
                      </volist>
                  </ul>
                </div>
                <div class="con-item-ft" style="text-align: center; padding:20px 0; background-color:rgba(255,255,255,0.6);">
                  <p class="coupon-tip"></p>
                  <a href="javascript:void(0);" class="btn S_cancel_coupon_btn" data-store="{$supp.store_id}" style=" font-size:12px;">取消使用</a> 
                  <a href="javascript:void(0);" class="btn S_select_coupon_btn btn-positive" data-store="{$supp.store_id}" style=" font-size:12px;">确认使用</a> 
                </div>
              </div>
                <!--{//运费}-->
                <php>$total_amount = get_store_amount($supp['store_id'],$supp['item'],$data['delivery'][$supp['store_id']]['price'],$buynow);</php>
                <if condition="$buynow eq 0">
                <php>$manjian_amount = get_store_manjian($supp['store_id'],true);</php>
                <else />
                <php>$manjian_amount = get_store_manjian($supp['store_id'],true, $buynow);</php>
                </if>
                <!--优惠券金额-->
                <gt name="supp.coupon_total" value="0">
                  <div style="width: 100%;background-color: #fff;  padding: 10px; text-align: right; " id="shop_coupon_{$supp.store_id}">
                    <label for="coupon_amount">优惠抵扣：</label>
                    <input type="hidden" class="store_coupons_fee" name="store_coupons_val[{$supp.store_id}]" value="0" />
                    <input type="hidden" name="store_coupons_use[{$supp.store_id}]" value="0" />
                    <input type="hidden" name="store_coupons_id[{$supp.store_id}]" value="0" />
                    <span>-0.00元</span>
                  </div>
                <else />
                  <input type="hidden" class="store_coupons_fee" name="store_coupons_val[{$supp.store_id}]" value="0" />
                  <input type="hidden" name="store_coupons_use[{$supp.store_id}]" value="0" />
                  <input type="hidden" name="store_coupons_id[{$supp.store_id}]" value="0" />
                </gt>
                <div style="width: 100%;background-color: #fff;  padding: 10px; text-align: right; ">
                  <span>店铺运费：</span><span>{:number_format($data['delivery'][$supp['store_id']]['price'],2)}元</span>
                  <input type="hidden" class="S_delivery_fee" name="store_freight[{$supp.store_id}]" value="{$data['delivery'][$supp['store_id']]['price']}" />
                  <notempty name="manjian_amount.code">
                  <span id="store-manjian-{$supp.store_id}" data-jian="{$manjian_amount['code']}">满减金额：</span><span>-{:number_format($manjian['code'],2,'.','')}元</span>
                  <input type="hidden" class="store_manjian_fee" name="store_manjian[{$supp.store_id}]" value="{$manjian_amount['code']}" />
                  <else />
                  <input type="hidden" data-jian="0"  id="store-manjian-{$supp.store_id}" class="store_manjian_fee" name="store_manjian_{$supp.store_id}" value="0" />
                  </notempty>
                </div>
                <div style="width: 100%;background-color: #fff;  padding: 10px; text-align: right; ">
                  <span>店铺合计：</span><span>{:number_format($total_amount,2,'.','')}元</span>
                  <input type="hidden" id="shop_order_{$supp.store_id}" class="store-items-amount" data-store="{$supp.store_id}" name="store_amount[{$supp.store_id}]" value="{$total_amount}">
                </div>
              </div>

            </volist>
          </div>
        </notempty>
      </div>
      <input type="hidden" name="buynowss" value="{$buynow}" />
      <div class="payment-ext Z_payment_list" style=" margin-top:10px;">
        <ul class="table-view">
          <!--{//礼品卡支付}-->
          <notempty name="data.cards.lists">
            <li class="table-view-cell" id="Z_order_card_box">
              <input type="checkbox" class="Z_payment_item" name="use_coupon" id="use_card">
              <i class="icon icon-square"></i> 使用礼品卡（<em class="text-danger">有可用礼品卡</em>） <i class="icon icon-arrow-bottom" id="Z_card_arrow"></i> 
            </li>
            <div class="payment-box hide Z_itemlist" id="Z_card_box">
              <div class="con-item-bd">
                <ul class="coupon-list" id="Z_card_list">
                  <volist name="data.cards.lists" id="vo">
                    <li>
                      <label for="cards_item_{$vo.Card.id}">
                        <input type="checkbox" name="order[cards][]" value="{$vo.Card.number}" id="cards_item_{$vo.Card.id}" />
                        <i>{$vo.Card.name}</i> <span>{$vo.Card.balance} 元</span> </label>
                    </li>
                  </volist>
                </ul>
              </div>
              <div class="con-item-ft"> <a href="javascript:void(0);" class="btn" id="Z_card_cancel">取消使用</a> <a href="javascript:void(0);" class="btn btn-positive" id="Z_card_check">确认使用</a> </div>
            </div>
          </notempty>
          <if condition="(C('SCORE_EXCHANGE_STATUS') eq 1) AND ($member['score'] gt 0)"> 
            <!--{//积分支付}-->
            <li class="table-view-cell" id="Z_order_score_box">
              <input type="checkbox" class="hide Z_payment_item" name="use_score_input" id="Z_use_score">
              <i class="icon icon-square"></i> 使用积分抵扣（可用：<em class="text-danger">{$member.score}</em> 积分） 
            </li>
          </if>
          <!--{//账户余额支付}-->
          <if condition="$member['finance'] gt 0">
            <li class="table-view-cell" id="Z_order_finance_box">
              <input type="checkbox" class="hide Z_payment_item" name="use_finance" id="Z_use_finance">
              <i class="icon icon-square"></i> 使用账户余额（可用余额：<em class="text-danger">{$member.finance}</em> 元） 
            </li>
          </if>
        </ul>
      </div>
      <!-- 订单支付信息汇总 -->
      <div class="count">
        <ul>
          <li>商品总价：<span id='J_delivery_amount'>{$order_count.total_price} 元</span></li>
          <!-- <li>运费：<span id="Z_delivery_fee">0 元</span></li>
          
          <notempty name="data.coupons.lists">
          <li>优惠券抵扣：<span id="Z_coupon_desc">-0 元</span></li>
          </notempty> -->
          
          <notempty name="data.cards.lists">
          <li>礼品卡抵扣：<span id="Z_card_desc">-0 元</span></li>
          </notempty>
          
          <if condition="(C('SCORE_EXCHANGE_STATUS') eq 1) AND ($member['score'] gt 0)"> 
          <li class="hide" id="Z_score_desc">积分抵扣：<span>-0 元</span></li>
          </if>
          
          <!-- <if condition="$order_count['manjian']">
            <li>满减优惠：<span id="Z_promote_desc" data-price="0">-{:sprintf('%.2f', $order_count['manjian'])} 元</span></li>
          </if>
          <if condition="session('user_auth.group_id') gt 0">
            <li>{:get_group_name(session('user_auth.group_id'))}：<span id="cardDesc">{:get_group_description(session('user_auth.group_id'))}</span></li>
          </if> -->
          
          <if condition="$member['finance'] gt 0">
          <li>账户余额支付：<span id="Z_finance_desc">-0 元</span></li>
          </if>
        </ul>
      </div>
      <input type="hidden" name="is_use_finance" id="Z_is_use_finance">
      <input type="hidden" name="coupon_id" id="Z_coupon_id">
      <input type="hidden" name="card_id" id="Z_card_id">
      <input type="hidden" name="use_score" id="Z_use_score_number">
      <input type="hidden" name="score_amount" id="Z_use_score_amount">
      <input type="hidden" name="buynow" id="buynow" value="{$buynow}">
      <input type="hidden" name="item_ids" id="Z_item_ids" value="{$item_ids}">
      <input type="hidden" name="cart_ids" id="Z_cart_ids" value="{$cart_ids}" />
      <input type="hidden" name="invoice_title" id="invoice_title" >
    </form>
  </div>
</block>

<!-- 底部tab -->
<block name="footer"> 
  <!--弹出发票信息 -->
  <include file="Order/invoice" />
  <div class="bar bar-tab"> 
    <span class="tab-text"> 应付总额：
      <strong class="text-danger" id="Z_total_price">
        <em class="yen">&yen;</em> {:sprintf('%.2f', $order_count['total_price'])}
      </strong> 
    </span> 
    <span class="pull-right cart-checkout"> 
      <a href="javascript:;" class="btn btn-negative btn-tab" id="Z_order_submit">提交订单</a> 
    </span> 
  </div>
</block>
<block name="script">
  <script>
    seajs.use(['order', 'cart' ,'invoice'], function(order, cart ,invoice){
      //满减规则
      C.manjianRule = {$order_count.manjian|json_encode};
      var total_price = order.getStoreMount();
      <if condition='C("REAL_NAME") eq 1 '>
        order.init(total_price,1);
      <else />
      order.init(total_price);
      </if>

      invoice.init();
      //
      cart.getSendItem({:I('get.buynow')});
    });
  </script> 
</block>
